﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;
using System.Collections;

namespace B2B.Models
{
    public class SP_SentEmail
    {
        int maEmail;

        public int MaEmail
        {
            get { return maEmail; }
            set { maEmail = value; }
        }
        string emailNguoiGui;

        public string EmailNguoiGui
        {
            get { return emailNguoiGui; }
            set { emailNguoiGui = value; }
        }
        string emailNguoiNhan;

        public string EmailNguoiNhan
        {
            get { return emailNguoiNhan; }
            set { emailNguoiNhan = value; }
        }
        string chuDe;

        public string ChuDe
        {
            get { return chuDe; }
            set { chuDe = value; }
        }
        string hoTen;

        public string HoTen
        {
            get { return hoTen; }
            set { hoTen = value; }
        }

        DateTime ngayGui;

        public DateTime NgayGui
        {
            get { return ngayGui; }
            set { ngayGui = value; }
        }

        public ArrayList danSachSentEmail(string emailNguoiGui)
        {
            ArrayList ds_Mail = new ArrayList();
            SqlConnection conn = KetNoi.Connection();
            SqlCommand cmd = new SqlCommand("SP_EMAILSENTBOX", conn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@EMAILNGUOIGUI", emailNguoiGui);
            conn.Open();
            SqlDataReader reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                SP_SentEmail sentEmail = new SP_SentEmail();
                sentEmail.MaEmail = reader.GetInt32(0);
                sentEmail.EmailNguoiGui = reader.GetString(1);
                sentEmail.EmailNguoiNhan = reader.GetString(2);
                sentEmail.ChuDe = reader.GetString(3);
                sentEmail.HoTen = reader.GetString(4);
                sentEmail.NgayGui = DateTime.Parse(reader.GetDateTime(5).ToShortDateString());
                ds_Mail.Add(sentEmail);
            }
            conn.Close();
            return ds_Mail;
        }
    }
}